﻿@using KPIS.GERP.Models.ViewModel
@using KPIS.GERP.Models.ICM
@model IEnumerable<PurchaseOrderItem>

@{
    Layout = "~/Views/Shared/_EmptyLayout.cshtml";
    ViewBag.Title = "รายการใบสั่งซื้อ/จ้าง";
    ViewBag.Descr = ViewBag.Title + " ที่ทางพัสดุทำรายการขอซื้อ/จ้าง";

    int intPoId = ViewBag.PoId;
    //"DeleteAll", "PurchaseOrderItem", FormMethod.Post
}
@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="row-fluid">    
        <div class="block-button-menu-above">
          @*  @if (ViewBag.bEditable)
            {
            @Html.ActionLink("เพิ่ม", "Create", new { PoId = intPoId }
            , new { @class="btn btn-small btn-success button-standard-width", role="button" })
            }
            @Html.ButtonDeleteAll()*@
        </div>

        <div class="alert-error">@Html.ValidationSummary()</div>
        <div class="row-fluid">
            <div class="table-header span12">
                <div class="span10">
					@ViewBag.Title
                </div>
				@Html.Partial("_ExportButton")
            </div>
        </div>

        <table id="table" class="table table-striped table-bordered table-hover" aria-describedby="table_info">
            <thead>
                <tr>
                    <th class="center" style="width:50px;">
						<!-- Check box delete multiple records column-->
                        <label>
                            <input type="checkbox" />
                            <span class="lbl"></span>
                        </label>
                    </th>
              
                       <th>
                        รายการพัสดุ/บริการ
                    </th>
                   @* <th>
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.SelectedReason)
                    </th>*@
                     <th>                       
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.Descr)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.Qty)
                    </th>
                     <th>
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.ExcludeVatAmount)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.Price)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.VatAmount)
                    </th>
                    <th>
                        @Html.DisplayNameFor(model => model.FirstOrDefault().BidderQuotation.NetAmount)
                    </th>
               
					<th class="center" style="width:80px;">
						<!-- Empty head column for export buttons -->&nbsp;
					</th>
                </tr>
            </thead>

            <tbody>
                @*@foreach (var m in Model ?? new List<PurchaseOrderItem>())                    *@
                @foreach (var m in Model)
                {
<tr>
                        <td class="center">
							<!-- Check box all for delete multiple records -->
                            <label>
                                <input type="checkbox" name="deleteIds" value="" disabled />
                                <span class="lbl"></span>
                            </label>
                        </td>
						<td>
                            @if (m.BidderQuotation.PurchaseRequestItem.ResItemId != null)
                            {
							    @Html.ActionLink(@m.BidderQuotation.PurchaseRequestItem.MasResourceItem.Name, "Details", new { Id = m.BidderQuotation.PrItemId })
                            }
                            else
                            {
                                @Html.ActionLink("ไม่ระบุพัสดุที่ซื้อ/จ้างทำ", "Details", new { Id = m.BidderQuotation.PrItemId })
                            }
						</td>
                        <td>
							@Html.DisplayFor(model => m.BidderQuotation.Descr)
						</td>
						<td style="text-align:right">
							@(m.BidderQuotation.Qty.HasValue ? m.BidderQuotation.Qty.Value.ToString("#,##0") : "0")
						</td>
                        <td style="text-align:right">
							@(m.BidderQuotation.ExcludeVatAmount.HasValue ? m.BidderQuotation.ExcludeVatAmount.Value.ToString("#,##0.00") : "0")
						</td>
						<td style="text-align:right">
							@(m.BidderQuotation.Price.HasValue ? m.BidderQuotation.Price.Value.ToString("#,##0.00") : "0")
						</td>
                        <td style="text-align:right">
							@(m.BidderQuotation.VatAmount.HasValue ? m.BidderQuotation.VatAmount.Value.ToString("#,##0.00") : "0")
						</td>
						<td style="text-align:right">
							@(m.BidderQuotation.NetAmount.HasValue ? m.BidderQuotation.NetAmount.Value.ToString("#,##0.00") : "0")
						</td>
                        <td class="td-actions">
                            @{
                                @Html.Partial("_ButtonMenuEachRow", new ExportGrid
                                {
                                    Id = (int)m.BidderQuoId,
                                    DetailsUrl = Url.Action("Details","BidderQuotation") + "/" + m.BidderQuoId
                                })                            
                            }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@section scripts {
    
	<script type="text/javascript">
		$(function () {
			var oTable1 = $('#table').dataTable({
				"aoColumns": [
                    { "bSortable": false },
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    { "bSortable": false }
				]
			});

		
			$('[data-rel=tooltip]').tooltip();

			

		})

	</script>

}